// 运行时配置文件

import { RequestConfig } from "umi";

// request 基础配置
export const request: RequestConfig = {
  baseURL: "https://m.maizuo.com/gateway",
  timeout: 1000 * 10,
  requestInterceptors: [
    (config: RequestConfig) => {
      // 从 config.url 中取出 x-host 的内容
      // "mall.film-ticket.film.list?cityId=440300&pageNum=1&pageSize=10&type=1&k=48732"
      const xHost = config.url?.split("?")[0] || "";
      config.url = config.url?.replace(xHost, "");
      // 给 headers 增加一个 x-host 字段
      config.headers!["X-Host"] = xHost;

      return config;
    },
  ],
  responseInterceptors: [],
};
